package com.heima.article.feign;

import com.heima.article.dto.ArticleDto;
import com.heima.article.entity.ApAuthor;
import com.heima.common.dto.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 作者远程调用feign
 */
@FeignClient(value = "leadnews-article")
public interface ArticleFeign {

    @PostMapping("/api/v1/author")
    public ResponseResult<ApAuthor> saveApAuthor(@RequestBody ApAuthor apAuthor);

    /**
     * 保存文章-提供给自媒体微服务远程调用
     * /api/v1/article
     * post
     *@return 文章发布后文章ID
     */
    @PostMapping("/api/v1/article")
    public ResponseResult<Long> saveArticle(@RequestBody ArticleDto articleDto);

    /**
     * 根据作者id查询作者
     * @param id 作者ID
     * @return
     */
    @GetMapping("/api/v1/author/{id}")
    public ResponseResult<ApAuthor> getAuthorById(@PathVariable("id") Integer id);
}
